Skip to content
This repository was archived by the owner on Jul 9, 2026. It is now read-only.

Implement jsdom node traversal properties - #1083

Merged
hypest merged 1 commit into
developfrom
try/implement-dom-node-traversal-properties
Jun 10, 2019
Merged

hypest merged 1 commit into
developfrom
try/implement-dom-node-traversal-properties

Conversation

@mkevins

@mkevins mkevins commented Jun 6, 2019

Copy link
Copy Markdown
Contributor

Fixes #827

Description

This PR aims to fix an issue on mobile (#827) where pasted content from certain sources omits the images. Related comment: #617 (review), and a clipboard snippet of html that reproduces the issue on mobile here: #827 (comment).

Steps to test:

  1. Select content from this site, including text above and below the image above "The Visual Editor.". Alternatively, if you are using an emulator with shared clipboard, it suffices to copy the html from the snippet referenced above.
  2. Create an empty paragraph block.
  3. Paste the contents.

Types of changes

When some content is pasted, a code path in figure-content-reducer.js expects parentElement property to be implemented when finding the containing <p> element (ancestor) surrounding an image element. Because parentElement is not implemented in the DOM for the mobile environment, <img> elements contained within <p> elements are not properly unwrapped, and are thus removed in a subsequent call to cleanNodeList.

It was noted in an earlier PR that we may encounter similar issues in other code paths as a result of our limited DOM implementation. These changes implement the parentElement property on the Node.prototype, as well as the previousElementSibling and nextElementSibling properties on the Node.prototype for all node implementing the NonDocumentTypeChildNode pure interface.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@mkevins mkevins added this to the v1.7 milestone Jun 6, 2019
@mkevins
mkevins requested a review from hypest June 6, 2019 07:33

@hypest hypest left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and pasting according to the test steps works nicely!

@hypest
hypest merged commit 409e70b into develop Jun 10, 2019
@hypest
hypest deleted the try/implement-dom-node-traversal-properties branch June 10, 2019 07:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pasting images along with text sometimes omits the images

2 participants